package com.ts.proj.controller;

import com.ts.base.controller.BaseController;
import com.ts.proj.entity.FileEntity;
import com.ts.proj.service.FileService;
import com.ts.util.DateUtil;
import com.ts.util.JurisdictionUtil;
import com.ts.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

//说明 字符串：Test，作为替换字符串

@Controller
public class FileController extends BaseController {

    @Autowired
    private FileService fileService;

    @RequestMapping("/errorproject-files-show/{uuid}/{state}")
    public ModelAndView errorfileShow(@PathVariable("uuid") String uuid,@PathVariable("state") String state) {
        ModelAndView modelAndView = this.getModelAndView();
        String viewName = "login";
        if(JurisdictionUtil.isValid()){
            PageData pd = new PageData();
            pd.put("deleteFlag", "N");
            pd.put("errorDetailId", uuid);
            pd.put("state", state);
            List<FileEntity> all = fileService.findAll(pd);
            modelAndView.addObject("all", all);
            viewName = "business/file/file-show";
        }
        modelAndView.setViewName(viewName);
        return modelAndView;
    }

    @RequestMapping("/project-files-show/{uuid}/{state}")
    public ModelAndView fileShow(@PathVariable("uuid") String uuid,@PathVariable("state") String state) {
        ModelAndView modelAndView = this.getModelAndView();
        String viewName = "login";
        if(JurisdictionUtil.isValid()){
            PageData pd = new PageData();
            pd.put("deleteFlag", "N");
            pd.put("uuid", uuid);
            pd.put("state", state);
            List<FileEntity> all = fileService.findAll(pd);
            modelAndView.addObject("all", all);
            viewName = "business/file/file-show";
        }
        modelAndView.setViewName(viewName);
        return modelAndView;
    }

    @RequestMapping("/project-touhou-files-show/{uuid}/{docType}")
    public ModelAndView docTypeFileShow(@PathVariable("uuid") String uuid,@PathVariable("docType") String docType) {
        ModelAndView modelAndView = this.getModelAndView();
        String viewName = "login";
        if(JurisdictionUtil.isValid()){
            PageData pd = new PageData();
            pd.put("deleteFlag", "N");
            pd.put("projId", uuid);
            pd.put("docType", docType);
            List<FileEntity> all = fileService.findAll(pd);
            modelAndView.addObject("all", all);
            viewName = "business/file/file-show";
        }
        modelAndView.setViewName(viewName);
        return modelAndView;
    }


    @RequestMapping("/project-juece-files-show/{uuid}/{docType}")
    public ModelAndView docTypeJueceFileShow(@PathVariable("uuid") String uuid,@PathVariable("docType") String docType) {
        ModelAndView modelAndView = this.getModelAndView();
        String viewName = "login";
        if(JurisdictionUtil.isValid()){
            PageData pd = new PageData();
            pd.put("deleteFlag", "N");
            pd.put("projId", uuid);
            pd.put("docType", docType);
            List<FileEntity> all = fileService.findAll(pd);
            modelAndView.addObject("all", all);
            viewName = "business/file/file-show";
        }
        modelAndView.setViewName(viewName);
        return modelAndView;
    }
}